{*******************************************************************************
* The contents of this file are used with permission, subject to the Mozilla   *
* Public License Version 1.1 (the "License"); you may not use this file except *
* in compliance with the License. You may obtain a copy of the License at      *
* http://www.mozilla.org/MPL/                                                  *
*                                                                              *
* Software distributed under the License is distributed on an "AS IS" basis,   *
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for *
* the specific language governing rights and limitations under the License.    *
*                                                                              *
* The Original Code is distributed as part of the "mediate" product and is     *
* Copyright (C) @home media limited. All Rights Reserved.                      *
*                                                                              *
* Email: support@athomemedia.co.uk                                             *
* Web:   http://www.athomemedia.co.uk                                          *
*******************************************************************************}

unit DesignerPropsMemo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons;

type
  TAHMDesignerPropsMemo = class(TForm)
    mmText: TMemo;
    btOkay: TButton;
    btClose: TButton;
    procedure mmTextKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
    FChanges: Boolean;
    function GetText: String;
    procedure SetText(Text: String);
    procedure SetChanges(Enabled: Boolean);
  public
    { Public declarations }
    property Text: String read GetText write SetText;
    property AllowChanges: Boolean read FChanges write SetChanges;
    function Display: Boolean;
  end;


implementation

{$R *.dfm}

procedure TAHMDesignerPropsMemo.mmTextKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  // Allow use of escape key to close form
  if Key = VK_ESCAPE then ModalResult := mrCancel;
end;

function TAHMDesignerPropsMemo.GetText: String;
begin
  Result := mmText.Text;
end;

procedure TAHMDesignerPropsMemo.SetText(Text: String);
begin
  mmText.Text := Text;
end;

procedure TAHMDesignerPropsMemo.SetChanges(Enabled: Boolean);
begin
  // Configure controls for readonly or read/write mode
  mmText.ReadOnly := not Enabled;
  btOkay.Visible := Enabled;
  if Enabled then btClose.Caption := 'Cancel' else btClose.Caption := 'Close';
  FChanges := Enabled;
end;

function TAHMDesignerPropsMemo.Display: Boolean;
begin
  Result := (Self.ShowModal = mrOK);
end;


end.
